/*
 * PpalForm.java
 *
 * Created on June 12, 2008, 8:21 PM
 */

package View;
import Model.Cliente;
import Model.Congreso;
import Model.Usuario;
import javax.swing.UIManager;
import com.birosoft.liquid.*;


import javax.swing.ImageIcon;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;


/**
 *
 * @author  Gigin
 */
public class PpalForm extends javax.swing.JFrame {
    private RPedidoForm mRPedidoForm;
    private SegPedidoForm mSegPedidoForm;
    private ECajaForm mECajasForm;
    private EStockForm mEStockForm;
    private ModoForm mModoForm;
    private ExportarForm mBaseDeDatos;
    private ClientesForm mClientesForm; 
    private CongresosForm mAltaCongresoForm;
    private UsuariosForm mModificaPermisosForm;
    private JDialog mAcercaDe;
    //private ReportesForm mReportesForm;
    private ReportesExcelForm mReportesForm;
    private AguardarForm mAguardar;
    
    private ImageIcon imagen = new ImageIcon(getClass().getResource("/logo_GTV4.gif"));
    
    //Si es modo congreso o oficina. Si es conreso tiene un congreso
    private String modo;
    private Congreso mCongreso;
    private Usuario mUsuario;
    
    private Container contenedor;
    private Container contenedor2;
    
    /** Creates new form PpalForm */
    public PpalForm() {
       // Se carga el Look and Feel
        try {
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");   
        } catch (Exception e) { }
        LiquidLookAndFeel.setStipples(false);
       // LiquidLookAndFeel.setLiquidDecorations(true, "mac"); 
      //  ImageIcon image = new ImageIcon("icono.ico");
      //  this.setIconImage(image.getImage());
     //   imagen=new ImageIcon(getClass().getResource("/logo_GTV4.gif"));
        this.setIconImage(imagen.getImage());
        initComponents();
        //this.jLabel1.setIcon(imagen);
        //this.jLabel1.setText("");
        
               
        contenedor = this.jPanel1;
        contenedor2 = this.jPanel1;
        this.setExtendedState(MAXIMIZED_BOTH);
        
        
        //Abre la pantalla para seleccionar el modo antes de entrar al sistema
        pantallaAguardar(this,"");
        //pantallaModo(this,"");
       
        
        
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButtonNuevoPedido = new javax.swing.JButton();
        jButtonSegPedidos = new javax.swing.JButton();
        jButtonCajas = new javax.swing.JButton();
        jButtonSegEnvios = new javax.swing.JButton();
        jButtonExportar = new javax.swing.JButton();
        jButtonClientes = new javax.swing.JButton();
        jButtonCongresos = new javax.swing.JButton();
        jButtonCambiaModo = new javax.swing.JButton();
        jButtonUsuarios = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabelCongreso = new javax.swing.JLabel();
        jButtonStock = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuArchivo = new javax.swing.JMenu();
        jMenuSalir = new javax.swing.JMenuItem();
        jMenuAyuda = new javax.swing.JMenu();
        jMenuContAyuda = new javax.swing.JMenuItem();
        jMenuAcercaDe = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SADC");

        jButtonNuevoPedido.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonNuevoPedido.setForeground(new java.awt.Color(94, 148, 189));
        jButtonNuevoPedido.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Realizar Pedido/realizarPed_normal.gif"))); // NOI18N
        jButtonNuevoPedido.setToolTipText("Realizar un nuevo pedido");
        jButtonNuevoPedido.setBorder(null);
        jButtonNuevoPedido.setBorderPainted(false);
        jButtonNuevoPedido.setContentAreaFilled(false);
        jButtonNuevoPedido.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Realizar Pedido/realizarPed_normal.gif"))); // NOI18N
        jButtonNuevoPedido.setFocusPainted(false);
        jButtonNuevoPedido.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Realizar Pedido/realizarPed_presionado.gif"))); // NOI18N
        jButtonNuevoPedido.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Realizar Pedido/realizarPed_mouse.gif"))); // NOI18N
        jButtonNuevoPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNuevoPedidoActionPerformed(evt);
            }
        });

        jButtonSegPedidos.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        jButtonSegPedidos.setForeground(new java.awt.Color(94, 148, 189));
        jButtonSegPedidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Seguimiento Pedidos/ped_normal.gif"))); // NOI18N
        jButtonSegPedidos.setToolTipText("Seguimiento de pedidos");
        jButtonSegPedidos.setBorder(null);
        jButtonSegPedidos.setBorderPainted(false);
        jButtonSegPedidos.setContentAreaFilled(false);
        jButtonSegPedidos.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Seguimiento Pedidos/ped_normal.gif"))); // NOI18N
        jButtonSegPedidos.setFocusPainted(false);
        jButtonSegPedidos.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Seguimiento Pedidos/ped_presionado.gif"))); // NOI18N
        jButtonSegPedidos.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Seguimiento Pedidos/ped_mouse.gif"))); // NOI18N
        jButtonSegPedidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSegPedidosActionPerformed(evt);
            }
        });

        jButtonCajas.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonCajas.setForeground(new java.awt.Color(94, 148, 189));
        jButtonCajas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/caj_normal.gif"))); // NOI18N
        jButtonCajas.setToolTipText("Ver caja");
        jButtonCajas.setBorder(null);
        jButtonCajas.setBorderPainted(false);
        jButtonCajas.setContentAreaFilled(false);
        jButtonCajas.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/caj_normal.gif"))); // NOI18N
        jButtonCajas.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/caj_presionado.gif"))); // NOI18N
        jButtonCajas.setRequestFocusEnabled(false);
        jButtonCajas.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/caj_mouse.gif"))); // NOI18N
        jButtonCajas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCajasActionPerformed(evt);
            }
        });

        jButtonSegEnvios.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonSegEnvios.setForeground(new java.awt.Color(94, 148, 189));
        jButtonSegEnvios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Envios/env_normal.gif"))); // NOI18N
        jButtonSegEnvios.setToolTipText("Seguimiento de envíos");
        jButtonSegEnvios.setBorder(null);
        jButtonSegEnvios.setContentAreaFilled(false);
        jButtonSegEnvios.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Envios/env_normal.gif"))); // NOI18N
        jButtonSegEnvios.setFocusPainted(false);
        jButtonSegEnvios.setFocusable(false);
        jButtonSegEnvios.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Envios/env_presionado.gif"))); // NOI18N
        jButtonSegEnvios.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Envios/env_mouse.gif"))); // NOI18N
        jButtonSegEnvios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSegEnviosActionPerformed(evt);
            }
        });

        jButtonExportar.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonExportar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonExportar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Exportar/exp_normal.gif"))); // NOI18N
        jButtonExportar.setToolTipText("Exportar e importar datos");
        jButtonExportar.setBorder(null);
        jButtonExportar.setBorderPainted(false);
        jButtonExportar.setContentAreaFilled(false);
        jButtonExportar.setFocusPainted(false);
        jButtonExportar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Exportar/exp_presionado.gif"))); // NOI18N
        jButtonExportar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Exportar/exp_mouse.gif"))); // NOI18N
        jButtonExportar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExportarActionPerformed(evt);
            }
        });

        jButtonClientes.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonClientes.setForeground(new java.awt.Color(94, 148, 189));
        jButtonClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Clientes/cliente_normal.gif"))); // NOI18N
        jButtonClientes.setToolTipText("Alta y modificación de clientes");
        jButtonClientes.setBorder(null);
        jButtonClientes.setBorderPainted(false);
        jButtonClientes.setContentAreaFilled(false);
        jButtonClientes.setFocusPainted(false);
        jButtonClientes.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Clientes/cliente_presionado.gif"))); // NOI18N
        jButtonClientes.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Clientes/cliente_mouse.gif"))); // NOI18N
        jButtonClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientesActionPerformed(evt);
            }
        });

        jButtonCongresos.setFont(new java.awt.Font("Verdana", 1, 12));
        jButtonCongresos.setForeground(new java.awt.Color(94, 148, 189));
        jButtonCongresos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Congresos/congresos_normal.gif"))); // NOI18N
        jButtonCongresos.setToolTipText("Alta y modificación de congresos");
        jButtonCongresos.setBorder(null);
        jButtonCongresos.setBorderPainted(false);
        jButtonCongresos.setContentAreaFilled(false);
        jButtonCongresos.setFocusPainted(false);
        jButtonCongresos.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Congresos/congresos_presionado.gif"))); // NOI18N
        jButtonCongresos.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Congresos/congresos_mouse.gif"))); // NOI18N
        jButtonCongresos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCongresosActionPerformed(evt);
            }
        });

        jButtonCambiaModo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Cambiar Modo/cm_normal.gif"))); // NOI18N
        jButtonCambiaModo.setToolTipText("Cambiar el modo de operación");
        jButtonCambiaModo.setBorderPainted(false);
        jButtonCambiaModo.setContentAreaFilled(false);
        jButtonCambiaModo.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Cambiar Modo/cm_normal.gif"))); // NOI18N
        jButtonCambiaModo.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Cambiar Modo/cm_presionado.gif"))); // NOI18N
        jButtonCambiaModo.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Cambiar Modo/cm_mouse.gif"))); // NOI18N
        jButtonCambiaModo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCambiaModoActionPerformed(evt);
            }
        });

        jButtonUsuarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Usuarios/usuario_normal.gif"))); // NOI18N
        jButtonUsuarios.setToolTipText("Alta y modificación de usuarios");
        jButtonUsuarios.setBorder(null);
        jButtonUsuarios.setBorderPainted(false);
        jButtonUsuarios.setContentAreaFilled(false);
        jButtonUsuarios.setFocusPainted(false);
        jButtonUsuarios.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Usuarios/usuario_presionado.gif"))); // NOI18N
        jButtonUsuarios.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Usuarios/usuario_mouse.gif"))); // NOI18N
        jButtonUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUsuariosActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Reportes/reportes_normal.gif"))); // NOI18N
        jButton1.setToolTipText("Ver reportes");
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Reportes/reportes_presionado.gif"))); // NOI18N
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Reportes/reportes_mouse.gif"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        jLabelCongreso.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
        jLabelCongreso.setForeground(new java.awt.Color(94, 148, 189));

        jButtonStock.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        jButtonStock.setForeground(new java.awt.Color(94, 148, 189));
        jButtonStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Stock/stock_normal.gif"))); // NOI18N
        jButtonStock.setToolTipText("Alta y modificación de congresos");
        jButtonStock.setBorder(null);
        jButtonStock.setBorderPainted(false);
        jButtonStock.setContentAreaFilled(false);
        jButtonStock.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Stock/stock_normal.gif"))); // NOI18N
        jButtonStock.setFocusPainted(false);
        jButtonStock.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Stock/stock_presionado.gif"))); // NOI18N
        jButtonStock.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Stock/stock_mouse.gif"))); // NOI18N
        jButtonStock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonStockActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Monotype Corsiva", 1, 24)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(94, 148, 189));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(34, 34, 34)
                                .addComponent(jLabel1)
                                .addGap(59, 59, 59)
                                .addComponent(jButtonNuevoPedido)
                                .addGap(18, 18, 18))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jButtonSegPedidos)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButtonSegEnvios))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(jButtonCajas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabelCongreso, javax.swing.GroupLayout.Alignment.LEADING))
                                            .addComponent(jButtonCambiaModo, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addComponent(jButtonStock))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(16, 16, 16)
                                                .addComponent(jButton1, 0, 0, Short.MAX_VALUE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonExportar)
                            .addComponent(jButtonUsuarios)
                            .addComponent(jButtonCongresos)
                            .addComponent(jButtonClientes)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(109, 109, 109)
                        .addComponent(jLabel2)))
                .addContainerGap(717, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel2)
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonExportar)
                    .addComponent(jButtonNuevoPedido)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonUsuarios, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButtonSegPedidos, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                        .addComponent(jButtonSegEnvios, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)))
                .addGap(23, 23, 23)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonCajas)
                    .addComponent(jButtonStock)
                    .addComponent(jButtonCongresos))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(188, 188, 188)
                        .addComponent(jLabelCongreso))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonCambiaModo, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButtonClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(513, 513, 513))
        );

        jMenuBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jMenuArchivo.setText("Archivo");

        jMenuSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/items_menu.gif"))); // NOI18N
        jMenuSalir.setText("Salir");
        jMenuSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuSalirActionPerformed(evt);
            }
        });
        jMenuArchivo.add(jMenuSalir);

        jMenuBar1.add(jMenuArchivo);

        jMenuAyuda.setText("Ayuda");

        jMenuContAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/items_menu.gif"))); // NOI18N
        jMenuContAyuda.setText("Contenidos de Ayuda");
        jMenuAyuda.add(jMenuContAyuda);

        jMenuAcercaDe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/items_menu.gif"))); // NOI18N
        jMenuAcercaDe.setText("AcercaDe");
        jMenuAcercaDe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuAcercaDeActionPerformed(evt);
            }
        });
        jMenuAyuda.add(jMenuAcercaDe);

        jMenuBar1.add(jMenuAyuda);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(76, 76, 76))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    /** NUEVO PEDIDO */
private void jButtonNuevoPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNuevoPedidoActionPerformed
     // Se crea la pantalla RPedidoForm     
    mRPedidoForm = new RPedidoForm(this.getModo(),this.getCongreso());
    mRPedidoForm.setPpal(this);
    cargarFormulario(mRPedidoForm);
  
    
}//GEN-LAST:event_jButtonNuevoPedidoActionPerformed

/** SEGUIMIENTO PEDIDOS */
private void jButtonSegPedidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSegPedidosActionPerformed
  // Se crea la pantalla SegPedidoForm     
    mSegPedidoForm = new SegPedidoForm(true,this.getModo(),this.getCongreso());
    mSegPedidoForm.setPpal(this);
    cargarFormulario(mSegPedidoForm);
}//GEN-LAST:event_jButtonSegPedidosActionPerformed

/** CAJAS */
private void jButtonCajasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCajasActionPerformed
    // Se crea la pantalla ECajasForm   
    mECajasForm = new ECajaForm(this.getModo(),this.getCongreso());
    mECajasForm.setPpal(this);
    cargarFormulario(mECajasForm);
}//GEN-LAST:event_jButtonCajasActionPerformed

/** SEGUMIENTO ENVIOS */
private void jButtonSegEnviosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSegEnviosActionPerformed
        // Se crea la pantalla SegPedidoForm
    
    mSegPedidoForm = new SegPedidoForm(false,this.getModo(),this.getCongreso());
    mSegPedidoForm.setPpal(this);
    cargarFormulario(mSegPedidoForm);
}//GEN-LAST:event_jButtonSegEnviosActionPerformed

/** EXPORTAR A BASE DE DATOS */
private void jButtonExportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportarActionPerformed
       mBaseDeDatos = new ExportarForm(this,true);
       
       Toolkit tk = Toolkit.getDefaultToolkit();
       Dimension screenSize = tk.getScreenSize();
       int screenHeight = screenSize.height;
       int screenWidth = screenSize.width;
       mBaseDeDatos.setLocation(screenWidth / 4, screenHeight / 4);
       
       mBaseDeDatos.setVisible(true);
}//GEN-LAST:event_jButtonExportarActionPerformed


/** ABM CLIENTES */
private void jButtonClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientesActionPerformed
    mClientesForm = new ClientesForm();
    mClientesForm.setPpal(this);
    cargarFormulario(mClientesForm);
}//GEN-LAST:event_jButtonClientesActionPerformed

/** ALTA CONGRESOS */
private void jButtonCongresosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCongresosActionPerformed
    mAltaCongresoForm = new CongresosForm();
    mAltaCongresoForm.setPpal(this);
    cargarFormulario(mAltaCongresoForm);
}//GEN-LAST:event_jButtonCongresosActionPerformed



/** ALTA USUARIOS */
private void jButtonUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUsuariosActionPerformed
    
    mModificaPermisosForm = new UsuariosForm();
    mModificaPermisosForm.setPpal(this);
    cargarFormulario(mModificaPermisosForm);
    
}//GEN-LAST:event_jButtonUsuariosActionPerformed

private void jButtonCambiaModoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCambiaModoActionPerformed
   
        pantallaModo(this,this.getModo());
}//GEN-LAST:event_jButtonCambiaModoActionPerformed

private void jMenuSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuSalirActionPerformed
       Object[] opciones ={"Si","No"};
       try{
       int selec = JOptionPane.showOptionDialog(new JFrame(), "¿Seguro que quiere salir?","Atención!",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, opciones, null);
       if(selec == 0){
            this.dispose();
            System.exit(0);
            
       }
        } catch(Exception e){
            
        }
}//GEN-LAST:event_jMenuSalirActionPerformed

private void jMenuAcercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuAcercaDeActionPerformed

       mAcercaDe = new AcercaDeForm(this,true);
       
       Toolkit tk = Toolkit.getDefaultToolkit();
       Dimension screenSize = tk.getScreenSize();
       int screenHeight = screenSize.height;
       int screenWidth = screenSize.width;
       mAcercaDe.setLocation(screenWidth / 4, screenHeight / 4);
       
       mAcercaDe.setVisible(true);
}//GEN-LAST:event_jMenuAcercaDeActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       /* mReportesForm = new ReportesForm(this.getModo(),this.getCongreso());
        mReportesForm.setPpal(this);
        cargarFormulario(mReportesForm);*/
    
        mReportesForm = new ReportesExcelForm(this.getModo(),this.getCongreso());
        mReportesForm.setPpal(this);
        cargarFormulario(mReportesForm);
        

}//GEN-LAST:event_jButton1ActionPerformed

private void jButtonStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStockActionPerformed
//JOptionPane.showMessageDialog(new JFrame(), "Ud no tiene los permisos suficientes para ingresar en esta sección"," ", JOptionPane.WARNING_MESSAGE);
mEStockForm = new EStockForm(this.getModo(),this.getCongreso());
    mEStockForm.setPpal(this);
    cargarFormulario(mEStockForm);
}//GEN-LAST:event_jButtonStockActionPerformed


public void pantallaModo(javax.swing.JFrame frame, String estado){
        mModoForm = new ModoForm(frame,estado);
        mModoForm.setPpal(this);
        estadoPanel(false,false);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        mModoForm.setLocation(screenWidth / 4, screenHeight / 4);
        mModoForm.setVisible(true);
}

public void pantallaAguardar(javax.swing.JFrame frame, String estado){
        mAguardar =new AguardarForm(this,true,this);
        estadoPanel(false,false);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        mAguardar.setLocation(screenWidth / 4, screenHeight / 4);
        mAguardar.setVisible(true);
}

public void cargarFormulario(javax.swing.JFrame frame){
        this.getContentPane().remove(contenedor);
        contenedor = frame.getContentPane();
        this.getContentPane().add(contenedor);
        this.setLayout(frame.getLayout());
        this.pack();
        this.setExtendedState(this.MAXIMIZED_BOTH);
    }
    
public void cargarFormulario(){
        
        this.getContentPane().remove(contenedor);
        contenedor = contenedor2;
        this.getContentPane().add(contenedor2);
        this.pack();
        this.setExtendedState(this.MAXIMIZED_BOTH);
}

public void cargarFormulario(String modo, Congreso cong, Usuario usr){
       this.setModo(modo);
       this.setCongreso(cong);
       this.setUsuario(usr);
       
       if(this.getModo().compareTo("Congreso") == 0){
            //jButtonExportar.setVisible(false);
            //jButtonClientes.setVisible(false);
            //jButtonCongresos.setVisible(false);
           // jButtonUsuarios.setVisible(false);
            jLabel2.setText("Congreso: "+cong.getNombreCong() + "(" + cong.getStockDvd() + ")");
            permisoUsuario(usr,false);
       }
       if(this.getModo().compareTo("Oficina") == 0){
           // jButtonExportar.setVisible(true);
            //jButtonClientes.setVisible(true);
            //jButtonCongresos.setVisible(true);
            jLabel2.setText("");
            //Chequea Permisos
            permisoUsuario(usr,true);
           
       }
       
}

private void permisoUsuario(Usuario usr, boolean oficina){
    boolean total=false;
    boolean nuevoP=false;
    boolean datos=false;
    boolean segPed=false;
    boolean segEnv=false;
    boolean usuarios=false;
    boolean caja=false;
    boolean stock=false;
    boolean congresos=false;
    boolean reportes=false;
    boolean clientes=false;
    if (!oficina){
        
        return;
    }
        
    for(int i=0;i<this.mUsuario.getPermiso().size();i++){
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Total"))
                    total=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("NuevoPedido"))
                    nuevoP=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("SeguimientoPedido"))
                    segPed=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("SeguimientoEnvio"))
                    segEnv=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Usuarios"))
                    usuarios=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Caja"))
                    caja=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Stock"))
                    stock=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Congresos"))
                    congresos=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Reportes"))
                    reportes=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Clientes"))
                    clientes=true;
        if (mUsuario.getPermiso().get(i).getDescripcion().equalsIgnoreCase("Datos"))
                    datos=true;
    }
    
    if(nuevoP)
        this.jButtonNuevoPedido.setVisible(true);
    else
        this.jButtonNuevoPedido.setVisible(false);
    
     if(segPed)
        this.jButtonSegPedidos.setVisible(true);
    else
        this.jButtonSegPedidos.setVisible(false);
    
     if(segEnv)
        this.jButtonSegEnvios.setVisible(true);
    else
        this.jButtonSegEnvios.setVisible(false);
    
     if(datos)
        this.jButtonExportar.setVisible(true);
    else
        this.jButtonExportar.setVisible(false);
    
     if(reportes && oficina)
        this.jButton1.setVisible(true);
    else
        this.jButton1.setVisible(false);
    
     if(congresos && oficina)
        this.jButtonCongresos.setVisible(true);
    else
        this.jButtonCongresos.setVisible(false);
    
     if(clientes && oficina)
        this.jButtonClientes.setVisible(true);
    else
        this.jButtonClientes.setVisible(false);
    
     if(stock)
        this.jButtonStock.setVisible(true);
    else
        this.jButtonStock.setVisible(false);
    
     if(caja)
        this.jButtonCajas.setVisible(true);
    else
        this.jButtonCajas.setVisible(false);
    
     if(usuarios && oficina)
        this.jButtonUsuarios.setVisible(true);
    else
        this.jButtonUsuarios.setVisible(false);
    if(total && oficina){

        this.jButtonNuevoPedido.setVisible(true);
        this.jButtonSegPedidos.setVisible(true);
        this.jButtonSegEnvios.setVisible(true);
        this.jButtonExportar.setVisible(true);
        this.jButton1.setVisible(true);
        this.jButtonCongresos.setVisible(true);
        this.jButtonClientes.setVisible(true);
        this.jButtonStock.setVisible(true);
        this.jButtonCajas.setVisible(true);
        this.jButtonUsuarios.setVisible(true);
    }
    if(total && !oficina){
                this.jButtonNuevoPedido.setVisible(true);
        this.jButtonSegPedidos.setVisible(true);
        this.jButtonSegEnvios.setVisible(true);
        this.jButtonExportar.setVisible(false);
        this.jButton1.setVisible(true);
        this.jButtonCongresos.setVisible(false);
        this.jButtonClientes.setVisible(false);
        this.jButtonStock.setVisible(true);
        this.jButtonCajas.setVisible(true);
        this.jButtonUsuarios.setVisible(false);
        
    }
        
}

public void estadoPanel(boolean estado,boolean cong){
    jButtonNuevoPedido.setEnabled(estado);
    jButtonSegPedidos.setEnabled(estado);
    jButtonCajas.setEnabled(estado);
    jButtonSegEnvios.setEnabled(estado);
    jButtonExportar.setEnabled(estado);
    jButtonClientes.setEnabled(estado);
    jButtonCongresos.setEnabled(estado);
    jButtonCambiaModo.setEnabled(estado);
    jButtonUsuarios.setEnabled(estado);
    jButtonExportar.setVisible(cong);
    jButtonClientes.setVisible(cong);
    jButtonCongresos.setVisible(cong);
    jButtonUsuarios.setVisible(cong);
    jButton1.setVisible(cong);

}

public Usuario getUsuario() {
        return mUsuario;
    }
    
public void setUsuario (Usuario val) {
        this.mUsuario = val;
    }
   
public String getModo() {
        return modo;
    }
    
public void setModo (String val) {
        this.modo = val;
    }

public Congreso getCongreso() {
        return this.mCongreso;
    }
    
public void setCongreso(Congreso val) {
        this.mCongreso = val;
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        
        Cliente cliente;
     /*Proxy.obtenerCongresos();
     Proxy.obtenerConjuntoExpandible(4);
     Proxy.obtenerConjuntoExpandible(5);
     Proxy.obtenerConjuntoExpandible(6);
     Proxy.obtenerConjuntoExpandible(7);
     Proxy.obtenerClientes();
     Proxy.obtenerApellidos();*/
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new PpalForm().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonCajas;
    private javax.swing.JButton jButtonCambiaModo;
    private javax.swing.JButton jButtonClientes;
    private javax.swing.JButton jButtonCongresos;
    private javax.swing.JButton jButtonExportar;
    private javax.swing.JButton jButtonNuevoPedido;
    private javax.swing.JButton jButtonSegEnvios;
    private javax.swing.JButton jButtonSegPedidos;
    private javax.swing.JButton jButtonStock;
    private javax.swing.JButton jButtonUsuarios;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabelCongreso;
    private javax.swing.JMenuItem jMenuAcercaDe;
    private javax.swing.JMenu jMenuArchivo;
    private javax.swing.JMenu jMenuAyuda;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuContAyuda;
    private javax.swing.JMenuItem jMenuSalir;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
